<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    </head>
    <body>
        <script type="text/javascript">
            var total=0;
            var num = parseInt(prompt("请输入考试科目数量"));
            if(num>0){
                for(var i=1;i<=num;i++){
                    var score = parseFloat(prompt("请输入成绩"));
                    if(score<0){
                    alert("分数录入有误！");
                    break;
                    }
                    total = total+score;
                }
                if(i==num+1){
                    alert(total);
                }
            }else{
                alert("科目数目不对！");
            }

        </script>
    </body>
</html>